package com.wjk.kylin.id.core.factory.impl;

import com.wjk.kylin.id.core.generator.impl.CachedIdGenerator;
import com.wjk.kylin.id.core.service.impl.HttpSegmentIdServiceImpl;
import com.wjk.kylin.id.core.factory.AbstractIdGeneratorFactory;
import com.wjk.kylin.id.core.generator.IdGenerator;

/**
 *
 */
public class IdGeneratorFactoryClient extends AbstractIdGeneratorFactory {
    private static IdGeneratorFactoryClient idGeneratorFactoryClient;

    private IdGeneratorFactoryClient() {
    }

    public static IdGeneratorFactoryClient getInstance() {
        if (idGeneratorFactoryClient == null) {
            synchronized (IdGeneratorFactoryClient.class) {
                if (idGeneratorFactoryClient == null) {
                    idGeneratorFactoryClient = new IdGeneratorFactoryClient();
                }
            }
        }

        return idGeneratorFactoryClient;
    }

    @Override
    public IdGenerator createIdGenerator(String bizType) {
        return new CachedIdGenerator(new HttpSegmentIdServiceImpl(bizType));
    }
//    @Override
//    public IdGenerator createIdGenerator(String bizType, Integer batchSize) {
//        return new CachedIdGenerator(new HttpSegmentIdServiceImpl(bizType, batchSize));
//    }
}
